home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / initramfs-tools / scripts / casper-premount / 30custom_installation < prev   
Encoding:
Text File  |  2008-07-09  |  3.3 KB  |  102 lines

  1. #!/bin/sh
  2.  
  3. PREREQ=""
  4. DESCRIPTION="Importing custom installation settings..."
  5.  
  6. . /scripts/casper-functions
  7.  
  8. prereqs()
  9. {
  10.        echo "$PREREQ"
  11. }
  12.  
  13. case $1 in
  14. # get pre-requisites
  15.     prereqs)
  16.            prereqs
  17.            exit 0
  18.            ;;
  19. esac
  20.  
  21. . /scripts/lupin-helpers
  22.  
  23. fix_preseed(){
  24.     #TBD what follows tries to find Linux devices if preseed is generated from another OS
  25.     #a proper fix should be to find reliable device mappings in the preseed-generator
  26.     preseed_file="$1"
  27.     preseed_dev="$2"
  28.     
  29.     #Find Linux device of User Folder for importing settings by m-a
  30.     user_folder=$(grep "#UserFolder" "$preseed_file" | sed 's/[[:space:]]*$//')
  31.     user_folder=${user_folder#'#UserFolder='}
  32.     if find_path  "$user_folder"; then
  33.         dev="$FOUNDDEV"
  34.     else
  35.         dev="$preseed_dev"
  36.     fi    
  37.     dev=${dev#/dev/}
  38.     sed -i "s:MADEVICE:$dev:g" "$preseed_file"
  39.     
  40.     #Find Linux device of loopinstall folder
  41.     loopinstall_folder=$(grep "#LoopInstallFolder" "$preseed_file" | sed 's/[[:space:]]*$//')
  42.     loopinstall_folder=${loopinstall_folder#'#LoopInstallFolder='}
  43.     if find_path  "${loopinstall_folder}"; then
  44.         dev="${FOUNDDEV}"
  45.     else
  46.         dev="$preseed_dev"
  47.     fi
  48.     check_loopinstall_folder "$dev" "$loopinstall_folder"
  49.     disk="$(echo "$dev" | sed 's/[0-9]*$//')"
  50.     partn=${dev#${disk}} 
  51.     sed -i "s:LIDISK:$disk:g" "$preseed_file"
  52.     sed -i "s:LIPARTITION:$partn:g" "$preseed_file"
  53. }
  54.  
  55. check_loopinstall_folder(){
  56.     loopinstall_dev=${1}
  57.     loopinstall_folder=${2}
  58.     
  59.     #TBD Check whether LOOPINSTALL_FOLDER is vergin or not
  60.     #Can we install on top of an existing installation?
  61.     #Shall we overwrite? ignore and simply boot the live CD or panic?
  62.     #Do we do the check here or later on?
  63. }
  64.  
  65. custom_installation_path=
  66. for x in $(cat /proc/cmdline); do
  67.     case ${x} in
  68.         debian-installer/custom-installation=*)
  69.             custom_installation_path=${x#debian-installer/custom-installation=}
  70.             ;;
  71.     esac
  72. done
  73. if [ -n "$custom_installation_path" ]; then
  74.     if find_path "${custom_installation_path}"; then
  75.         custom_installation_path="$FOUNDPATH"
  76.         custom_installation_dev="$FOUNDDEV"
  77.         mkdir -p /custom-installation
  78.         cp -af "$custom_installation_path"/* /custom-installation/
  79.         cp -af /custom-installation/initrd-override/* / || true
  80.         rm -rf /custom-installation/initrd-override || true
  81.         if [ -x /custom-installation/hooks/casper-premount.sh ]; then
  82.             /custom-installation/hooks/casper-premount.sh
  83.         fi
  84.         if [ -e /custom-installation/preseed.cfg ]; then
  85.             cp /custom-installation/preseed.cfg /
  86.             #fix parameters that cannot be set from a non-linux OS
  87.             fix_preseed /preseed.cfg "$custom_installation_dev"
  88.         fi
  89.     else
  90.         panic "
  91. Could not find the installation files $custom_installation_path
  92. This could also happen if the file system is not clean because of an operating
  93. system crash, an interrupted boot process, an improper shutdown, or unplugging
  94. of a removable device without first unmounting or ejecting it.  To fix this,
  95. simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
  96. gracefully shut down and reboot back into Windows. After this you should be
  97. able to reboot again and resume the installation.
  98. "
  99.     fi
  100.     find_path_cleanup
  101. fi
  102.